<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <meta name="inspire" content="https://codepen.io/nocni_sovac/pen/vYGoZpP">
</head>
<body>
    <style>
        * {
        margin: 0;
        padding: 0;
        }

        body {
        background: radial-gradient(circle, #131111 0%, black 17%, black 27%);
        height: 100vh;
        font-family: "Fira Mono", monospace;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: hidden;
        }

        .cursor {
        width: 40px;
        height: 40px;
        border: 3px solid white;
        border-radius: 50%;
        position: absolute;
        box-shadow: 2px -3px 41px -1px rgba(250, 250, 250, 0.64);
        pointer-events: none;
        }

        .side-menu {
        width: 200px;
        height: 100vh;
        position: absolute;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        }
        .side-menu #menuBtn {
        position: absolute;
        top: 25px;
        right: 25px;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        z-index: 99;
        height: auto;
        }
        .side-menu #menuBtn input {
        display: block;
        cursor: pointer;
        position: absolute;
        height: 100%;
        width: 100%;
        opacity: 0;
        z-index: 9;
        top: 10px;
        }
        .side-menu #menuBtn input:checked ~ span:nth-child(2) {
        transform-style: preserve-3d;
        animation: rotation 1s linear infinite;
        }
        @keyframes rotation {
        0% {
            transform: rotateX(0deg);
        }
        50% {
            transform: rotateX(180deg);
        }
        100% {
            transform: rotateZ(180deg);
        }
        }
        .side-menu #menuBtn input:checked ~ span:nth-child(3) {
        width: 21px;
        height: 1px;
        transform: rotate(90deg);
        }
        .side-menu #menuBtn span {
        position: relative;
        display: block;
        margin: 4px 0;
        border-radius: 2px;
        transition: all 0.2s linear;
        }
        .side-menu #menuBtn span:nth-child(2) {
        transform-style: preserve-3d;
        width: 35px;
        height: 35px;
        border: 1px solid white;
        border-radius: 100%;
        }
        .side-menu #menuBtn span:nth-child(3) {
        width: 3px;
        height: 3px;
        background: white;
        margin-top: -23px;
        }
        .side-menu .menu {
        text-align: right;
        display: none;
        }
        .side-menu .menu a {
        display: block;
        color: white;
        text-decoration: none;
        margin: 25px 0;
        font-size: 23px;
        }
        .side-menu .straight-line {
        margin: 35px 0;
        height: 2px;
        border: 0;
        background: linear-gradient(to right, #000000 0%, #dffff4 40%, #c1ffea 60%, #000000 100%);
        width: 0vh;
        left: 5%;
        position: relative;
        transform: translateX(-50%) rotate(90deg);
        position: absolute;
        }

        .mainText {
        width: 50%;
        margin-left: -430px;
        margin-top: 74px;
        }
        .mainText .mainTitle {
        text-transform: uppercase;
        color: #fff;
        font-size: 60px;
        position: relative;
        letter-spacing: 10px;
        position: relative;
        display: block;
        font-family: "Poppins", sans-serif;
        text-transform: uppercase;
        -webkit-text-stroke: 2px #ffffff;
        text-stroke: 2px #ffffff;
        -webkit-text-fill-color: transparent;
        text-fill-color: transparent;
        color: transparent;
        transition: all 0.4s linear;
        opacity: 0.5;
        user-select: none;
        }
        .mainText .mainTitle:hover {
        opacity: 1;
        -webkit-text-fill-color: white;
        text-fill-color: white;
        }
        .mainText .mainTitle:hover ~ .cursor {
        transform: scale(1.4);
        mix-blend-mode: difference;
        background: white;
        }
        .mainText .subTitle {
        text-transform: uppercase;
        color: #fff;
        font-size: 20px;
        position: relative;
        }

        .planetImg {
        transform: scale(0.7) rotate(158deg);
        position: absolute;
        top: -5%;
        right: 13%;
        animation: float 12s ease-in-out infinite;
        }

        @keyframes float {
        0% {
            box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
            transform: translatey(0px) translatex(5px) scale(0.7) rotate(156deg);
        }
        50% {
            box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
            transform: translatey(-20px) translatex(-5px) scale(0.7) rotate(162deg);
        }
        100% {
            box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
            transform: translatey(0px) translatex(5px) scale(0.7) rotate(156deg);
        }
        }
        .explosion {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        position: absolute;
        transition-duration: 10ms;
        transition-timing-function: ease-out;
        animation: meniItemClick 0.3s;
        }

        @keyframes meniItemClick {
        0% {
            transform: scale(0.3);
            box-shadow: 0 0 0px 0px #9ab3f5;
        }
        70% {
            transform: scale(1);
            opacity: 0.7;
            box-shadow: 0 0 10px 8px #9ab3f5;
        }
        100% {
            transform: scale(2);
            opacity: 0;
            box-shadow: 0 0 0px 0px #9ab3f5;
        }
        }
        #WebGL-output {
        width: 100%;
        height: 100%;
        position: absolute;
        }

        .dg {
        display: none;
        }

</style>


    <div id="WebGL-output">
    </div>
    
    <div class="side-menu">
      <div id="menuBtn">
        <input type="checkbox" />
        <span></span>
        <span></span>
      </div>
      <div class="menu">
        <a class="menu-item" href="#">HOME</a>
        <a class="menu-item" href="#">ABOUT US</a>
        <a class="menu-item" href="#">OUR WORK</a>
        <a class="menu-item" href="#">CAREERS</a>
        <a class="menu-item" href="#">CONTACT US</a>
      </div>
      <div class="straight-line"></div>
    </div>
    
    <img class="planetImg" src="https://assets.codepen.io/1651485/planet.png" />
    
    <div class="mainText">
      <div class="mainTitle">
        和 Milvus 一起探索真实世界的数据
      </div>
      <div class="subTitle">
        为源自中国的先进向量数据库开源软件，一键三连吧（👀🌟🍴）
      </div>
      <div class="cursor"></div>
    </div>


    <script>
let menuBtn = document.querySelector("#menuBtn");
let curs = document.querySelector(".cursor");
let menuItems = document.querySelectorAll(".menu-item");
let mainText = document.querySelector(".mainText");

document.addEventListener("mousemove", (e) => {
  let x = e.pageX;
  let y = e.pageY;
  curs.style.left = x - 15 + "px";
  curs.style.top = y - 15 + "px";
});

// show hide menu animation
let flag = true;
menuBtn.addEventListener("click", () => {
  flag = !flag;

  if (!flag) {
    gsap.to(".straight-line", {
      width: 700,
      duration: 0.3
    });
    gsap.to(".menu", {
      display: "block",
      duration: 0.3
    });
  } else {
    gsap.to(".straight-line", {
      width: 0,
      duration: 0.2
    });
    gsap.to(".menu", {
      display: "none",
      duration: 0.2
    });
  }
});

// menu item click animation and changing maim title

menuItems.forEach((item, index) => {
  item.addEventListener("click", () => {
    curs.classList.add("explosion");
    setTimeout(function () {
      curs.classList.remove("explosion");
    }, 900);
  });
});

// Taken from https://codepen.io/enesser/pen/jdenE

function main() {
  let scene = new THREE.Scene();
  let camera = new THREE.PerspectiveCamera(
    45,
    window.innerWidth / window.innerHeight,
    0.1,
    1000
  );
  let webGLRenderer = new THREE.WebGLRenderer();
  webGLRenderer.setClearColor(new THREE.Color(0x000000, 1.0));
  webGLRenderer.setSize(window.innerWidth, window.innerHeight);
  webGLRenderer.shadowMapEnabled = true;

  camera.position.x = -30;
  camera.position.y = 40;
  camera.position.z = 50;
  camera.lookAt(new THREE.Vector3(10, 0, 0));

  document.querySelector("#WebGL-output").append(webGLRenderer.domElement);

  let step = 0;

  let knot;

  let controls = new (function () {
    this.radius = 40;
    this.tube = 17;
    this.radialSegments = 186;
    this.tubularSegments = 4;
    this.p = 9;
    this.q = 1;
    this.heightScale = 4;
    this.asParticles = true;
    this.rotate = true;

    this.redraw = function () {
      if (knot) scene.remove(knot);

      let geom = new THREE.TorusKnotGeometry(
        controls.radius,
        controls.tube,
        Math.round(controls.radialSegments),
        Math.round(controls.tubularSegments),
        Math.round(controls.p),
        Math.round(controls.q),
        controls.heightScale
      );

      if (controls.asParticles) {
        knot = createParticleSystem(geom);
      } else {
        knot = createMesh(geom);
      }

      scene.add(knot);
    };
  })();

  let gui = new dat.GUI();
  gui.add(controls, "radius", 0, 40).onChange(controls.redraw);
  gui.add(controls, "tube", 0, 40).onChange(controls.redraw);
  gui.add(controls, "radialSegments", 0, 400).step(1).onChange(controls.redraw);
  gui.add(controls, "tubularSegments", 1, 20).step(1).onChange(controls.redraw);
  gui.add(controls, "p", 1, 10).step(1).onChange(controls.redraw);
  gui.add(controls, "q", 1, 15).step(1).onChange(controls.redraw);
  gui.add(controls, "heightScale", 0, 5).onChange(controls.redraw);
  gui.add(controls, "asParticles").onChange(controls.redraw);
  gui.add(controls, "rotate").onChange(controls.redraw);

  gui.close();

  controls.redraw();

  render();

  function generateSprite() {
    let canvas = document.createElement("canvas");
    canvas.width = 16;
    canvas.height = 16;

    let context = canvas.getContext("2d");
    let gradient = context.createRadialGradient(
      canvas.width / 2,
      canvas.height / 2,
      0,
      canvas.width / 2,
      canvas.height / 2,
      canvas.width / 2
    );
    gradient.addColorStop(0, "rgba(255,255,255,1)");
    gradient.addColorStop(0.2, "rgba(0,255,255,1)");
    gradient.addColorStop(0.4, "rgba(0,0,64,1)");
    gradient.addColorStop(1, "rgba(0,0,0,1)");

    context.fillStyle = gradient;
    context.fillRect(0, 0, canvas.width, canvas.height);

    let texture = new THREE.Texture(canvas);
    texture.needsUpdate = true;
    return texture;
  }

  function createParticleSystem(geom) {
    let material = new THREE.ParticleBasicMaterial({
      color: 0xffffff,
      size: 2,
      transparent: true,
      blending: THREE.AdditiveBlending,
      map: generateSprite()
    });

    let system = new THREE.ParticleSystem(geom, material);
    system.sortParticles = true;
    return system;
  }

  function createMesh(geom) {
    let meshMaterial = new THREE.MeshNormalMaterial({});
    meshMaterial.side = THREE.DoubleSide;

    let mesh = THREE.SceneUtils.createMultiMaterialObject(geom, [meshMaterial]);

    return mesh;
  }

  function render() {
    if (controls.rotate) {
      knot.rotation.y = step += 0.00058;
    }

    requestAnimationFrame(render);
    webGLRenderer.render(scene, camera);
  }
}
main();

    </script>

    
</body>
</html>